from django.db import models


#  部门表
class Department(models.Model):
    d_name = models.CharField('部门名称', max_length=30)

    class Meta:
        db_table = 'tb_department'
        verbose_name = "部门"
        verbose_name_plural = verbose_name

    def __str__(self):
        return self.d_name


#  员工表
class Staff(models.Model):
    name = models.CharField('员工名', max_length=30)
    role = models.IntegerField('员工职位(0:普通员工,1:部门领导,2:超级管理员)')
    depart = models.ForeignKey(Department, on_delete=models.CASCADE, verbose_name='所属部门')

    class Meta:
        db_table = 'tb_staff'
        verbose_name = "员工"
        verbose_name_plural = verbose_name

    def __str__(self):
        return self.name


#  加班表
class Work(models.Model):
    date = models.DateField('日期')
    start = models.TimeField('开始时间')
    end = models.TimeField('结束时间')
    role = models.IntegerField('是否同意加班(0:同意加班,1:不同意加班)')
    staff = models.ForeignKey(Staff, on_delete=models.CASCADE, verbose_name='员工加班')

    class Meta:
        db_table = 'tb_work'
        verbose_name_plural = '加班'

    def __str__(self):
        return self.staff
